﻿using System.Collections.Generic;
using Fabrication.Tests.TestClasses;
using NUnit.Framework;

namespace Fabrication.Tests
{
    [TestFixture]
    public class generic_collection_interfaces
    {
        [Test]
        public void should_set_generic_icollection_properties_to_empty_collection()
        {
            var builtItem = new FabricationScope()
                .Generate<SinglePropertyClass<ICollection<string>>>();

            Assert.That(builtItem.Value, Is.Not.Null);
        }

        [Test]
        public void should_populate_icollections_with_set_number_of_simple_element_types()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<ICollection<int>>>()
                .For(x => x.Value).Generate(5)
                .Generate();

            Assert.That(builtItem.Value.Count, Is.EqualTo(5));
        }

        [Test]
        public void should_populate_icollections_with_random_number_of_simple_element_types()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<ICollection<int>>>()
                .For(x => x.Value).Generate(11, 15)
                .Generate();

            Assert.That(builtItem.Value.Count, Is.InRange(11, 15));
        }

        [Test]
        public void should_populate_icollections_with_set_number_of_complex_element_types()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<ICollection<InnerClass>>>()
                .For(x => x.Value).Generate(5)
                .Generate();

            Assert.That(builtItem.Value.Count, Is.EqualTo(5));
        }

        [Test]
        public void should_populate_icollections_with_random_number_of_complex_element_types()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<ICollection<InnerClass>>>()
                .For(x => x.Value).Generate(11, 15)
                .Generate();

            Assert.That(builtItem.Value.Count, Is.InRange(11, 15));
        }
    }
}